﻿
-- =============================================
-- Author:		<XFL>
-- Create date: <20111219>
-- Description:	<通过用户的登陆账号，查询出用户的基本信息：姓名、单位、部门、职级、岗位>
-- =============================================
CREATE PROCEDURE [dbo].[proc_NetUser_login_user_msg] 
	-- UserName  is Session["USERID"]
	@UserName nvarchar(50)
	
AS
BEGIN
	SET NOCOUNT ON;
    Select [userId] as [ID],
			UserName,
			[Name] as [Name],			
			--(Select aspnet_Users.CompanyId from aspnet_Users Where aspnet_Users.UserName=@UserName) as NCompanyId,
			--(select CompanyName from Company where Id = (Select aspnet_Users.CompanyId from aspnet_Users Where aspnet_Users.UserName=@UserName)) as CompanyName,			
			/*获取单位信息:单位ID 单位名称*/
			CompanyId as NCompanyId,
			(Select CompanyName From Company Where Id = aspnet_Users.CompanyId) As CompanyName,			

			/*获取部门信息:部门ID 部门名称*/
			IsNull(DepartmentId,0) AS DepartmentId,
			IsNull((Select Sex From Employee Where Employee.UserName = aspnet_Users.UserName),'未知') As Sex,
			IsNull((Select DName From Department Where Id = DepartmentId),'---') As DepartmentName,
			IsNull((Select DepartmentId From Employee Where Employee.UserName = aspnet_Users.UserName),'0') As EDeptId
--			/*获取岗位类别信息:岗位类别ID 岗位类别名称*/
--			IsNULL(PostCategory,0) AS PostCategory,
--			isnull((select Title from Post_Category where Post_Category.Id = PostCategory),'...') as PostCategoryName,
--			
--			/*获取岗位信息:岗位ID 岗位名称*/
--            PostId,
--			(select PostName from Post where Id = Employee.PostId) as PostName,
--
--			/*获取职级信息:职级ID 职级名称*/
--			GradeId,
----			(select Title from Grade where Id = GradeId) as GradeName			
--		from
--			Employee
,(SELECT COUNT(1) FROM aspnet_Users WHERE rootid=@UserName and [IsLockout]=0) AS rootid_C
		From aspnet_Users
		Where username=@UserName
END